#!/bin/bash
export C_FORCE_ROOT="true"
base_dir=`pwd`


celery_pid() {
    echo `ps -ef | grep -E "celery -A celery_task worker" | grep -v grep| awk '{print $2}'`
}
start() {
    celery  multi start celery_task -A celery_task -l debug --autoscale=50,5 --logfile=$base_dir/var/celery-%I.log --pidfile=celery_task.pid
}
restart() {
    celery  multi restart celery_task -A celery_task -l debug
}
stop() {
    celery  multi stop celery_task -A celery_task -l debug
}
#restart(){
#    stop
#    start
#}


# See how we were called.
case "$1" in
  start)
        start
        ;;
  restart)
        restart
        ;;
  stop)
        stop
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 2
esac

#nohup celery -A celery_task worker -l debug --concurrency=10 --autoreload  & >>celery.log